
package flc.ast.dialog;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.AttachPopupView;

import flc.ast.R;

public class AddDialog extends AttachPopupView implements View.OnClickListener {


    public AddDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_add;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        initView();
    }

    protected void initView() {
        findViewById(R.id.tvAddFolder).setOnClickListener(this);
        findViewById(R.id.tvAddText).setOnClickListener(this);
        findViewById(R.id.tvSystemFile).setOnClickListener(this);
        findViewById(R.id.tvImportPicture).setOnClickListener(this);
        findViewById(R.id.tvPaste).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tvAddFolder) {
            dismiss();
            if (listener != null) {
                listener.clickAddFolder();
            }
        } else if (id == R.id.tvAddText) {
            dismiss();
            if (listener != null) {
                listener.clickAddText();
            }
        } else if (id == R.id.tvSystemFile) {
            dismiss();
            if (listener != null) {
                listener.clickSystemFile();
            }
        } else if (id == R.id.tvImportPicture) {
            dismiss();
            if (listener != null) {
                listener.clickImportPicture();
            }
        } else if (id == R.id.tvPaste) {
            dismiss();
            if (listener != null) {
                listener.clickPaste();
            }
        }
    }

    private Ilistener listener;

    public void setListener(Ilistener listener) {
        this.listener = listener;
    }

    public interface Ilistener {
        void clickAddFolder();

        void clickAddText();

        void clickSystemFile();

        void clickImportPicture();

        void clickPaste();
    }

}
